From d4662ee456eef8873c23f1400c60b93c0ca835eb Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Date: Mon, 7 Dec 2015 09:18:37 +0200
Subject: [PATCH 06/27] sunxi: disp2: FBIO_WAITFORVSYNC as a modifier for
 FBIOPAN_DISPLAY

Change the code logic so that the FBIO_WAITFORVSYNC ioctl affects
the behaviour of exactly one next FBIOPAN_DISPLAY ioctl and makes
it wait for vsync.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
---
 drivers/video/sunxi/disp2/disp/dev_fb.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/video/sunxi/disp2/disp/dev_fb.c b/drivers/video/sunxi/disp2/disp/dev_fb.c
index 070675c..3c83abe 100755
--- a/drivers/video/sunxi/disp2/disp/dev_fb.c
+++ b/drivers/video/sunxi/disp2/disp/dev_fb.c
@@ -524,6 +524,8 @@ static int fb_wait_for_vsync(struct fb_info *info)
 	return 0;
 }
 
+static int wait_for_vsync_flag;
+
 static int sunxi_fb_pan_display(struct fb_var_screeninfo *var,struct fb_info *info)
 {
 	u32 sel = 0;
@@ -562,7 +564,10 @@ static int sunxi_fb_pan_display(struct fb_var_screeninfo *var,struct fb_info *in
 		}
 	}
 
-	fb_wait_for_vsync(info);
+	if (wait_for_vsync_flag) {
+		wait_for_vsync_flag = 0;
+		fb_wait_for_vsync(info);
+	}
 
 	return 0;
 }
@@ -874,7 +879,7 @@ static int sunxi_fb_ioctl(struct fb_info *info, unsigned int cmd,unsigned long a
 
 	case FBIO_WAITFORVSYNC:
 	{
-		//ret = fb_wait_for_vsync(info);
+		wait_for_vsync_flag = 1;
 		break;
 	}
 
-- 
1.9.1

